home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / scope / 051-075 / scopedisk55 / dirk2 / sys.c < prev    next >
C/C++ Source or Header  |  1995-03-18  |  2KB  |  82 lines

  1. /***************************************************************************
  2.     1/89
  3.  
  4.         DIRK v2.0 -- Tune workbench colors to system performance
  5.  
  6.         Copyright (C) 1989 by Daniel Elbaum
  7.  
  8.         This software is freely redistributable provided that:
  9.         the four files which comprise it (dirk, dirk.doc, dirk.h,
  10.         adjust.c, main.c, sys, window.c) remain intact; all
  11.         copyright notices contained in any of the aforementioned
  12.         files remain intact; and no fee beyond reasonable remuneration
  13.         for collation and distribution be charged for use and/or
  14.         distribution.
  15.  
  16. ***************************************************************************/
  17.  
  18.  
  19. #include "dirk.h"
  20.  
  21. /*
  22.     Find the total amount of system memory
  23.     by cruising the master list.
  24. */
  25.  
  26. ULONG
  27. totmem()
  28. {
  29.     register ULONG tu, tl, tm=0;
  30.     register struct Node *n;
  31.     register struct MemHeader *m;
  32.  
  33.     Disable();
  34.     for (n=SysBase->MemList.lh_Head; n->ln_Succ; n=n->ln_Succ){
  35.         m=(struct MemHeader *)n;
  36.         tu=(ULONG)m->mh_Upper;
  37.         tl=(ULONG)m->mh_Lower;
  38.         tm+=tu-tl;
  39.     }
  40.     Enable();
  41.     return(tm);
  42. }
  43.  
  44. /*
  45.     Hunt up all ready tasks and waiting tasks;
  46.     put their respective counts in r and w.
  47. */
  48.  
  49. tqlen(r, w)
  50. int *r, *w;
  51. {
  52.     register tr=0, tw=0;
  53.     register struct Task *t;
  54.  
  55.     Disable();
  56.     t=SysBase->TaskReady.lh_Head;
  57.     for (tr=0; t->tc_Node.ln_Succ; t=t->tc_Node.ln_Succ)
  58.         tr++;
  59.     t=SysBase->TaskWait.lh_Head;
  60.     for (tw=0; t->tc_Node.ln_Succ; t=t->tc_Node.ln_Succ)
  61.         tw++;
  62.     Enable();
  63.     *r=tr;
  64.     *w=tw;
  65.     return(tr+tw);
  66. }
  67.  
  68. /*
  69.     Place amt of free chip mem into cm;
  70.     place amt of free fast mem into fm.
  71. */
  72.  
  73. ULONG
  74. amtfree()
  75. {
  76.     ULONG c, f;
  77.  
  78.     c=AvailMem(MEMF_CHIP);
  79.     f=AvailMem(MEMF_FAST);
  80.     return(c+f);
  81. }
  82.